(function() {
  $(function() {
    var form, layout, syntax, table_active_unique;
    form = $('form.main');
    layout = Cookies.get('settings.layout_style');
    if (layout) {
      form.form('set value', 'layout_style', layout);
    }
    syntax = Cookies.get('settings.syntax_style');
    if (syntax) {
      form.form('set value', 'syntax_style', syntax);
    }
    table_active_unique = Cookies.get('settings.table_active_unique');
    if (table_active_unique === 'on') {
      form.find('.checkbox#table_active_unique').checkbox('check');
    } else {
      form.find('.checkbox#table_active_unique').checkbox('uncheck');
    }
    return $('button#ok').click(function() {
      $(this).addClass('loading disabled');
      layout = form.form('get value', 'layout_style');
      Cookies.set('settings.layout_style', layout, {
        expires: 365,
        path: '/'
      });
      syntax = form.form('get value', 'syntax_style');
      Cookies.set('settings.syntax_style', syntax, {
        expires: 365,
        path: '/'
      });
      table_active_unique = form.form('get value', 'table_active_unique');
      return Cookies.set('settings.table_active_unique', table_active_unique, {
        expires: 365,
        path: '/'
      });
    });
  });

}).call(this);
